---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\fsu2010\formateur\replication\stata_mxl_predictprob.log
  log type:  text
 opened on:  11 Nov 2010, 14:42:21

. #delimit ;
delimiter now ;
. set mem 30m;

Current memory allocation

                    current                                 memory usage
    settable          value     description                 (1M = 1024k)
    --------------------------------------------------------------------
    set maxvar         5000     max. variables allowed           1.947M
    set memory           30M    max. data space                 30.000M
    set matsize         400     max. RHS vars in models          1.254M
                                                            -----------
                                                                33.201M

. clear matrix;

. clear mata;

. set more off;

. *     ***************************************************************** *;
. *     ***************************************************************** *;
. *       File-Name:  stata_mxl_predictprob.do                            *;
. *       Date:       November 9, 2010                                    *;
. *       Author:     GG/MG                                               *;
. *       Purpose:    Produces Figure 1 in AJPS paper                     *;
. *       Input File:     europe.dta                                      *;
. *       Output File:    stata_mxl_predictprob.log                       *;
. *       Data Output:    none                                            *;
. *       Previous file:  europe.dta                                      *;
. *       Machine:        Matt's desktop                                  *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. use "C:\fsu2010\formateur\replication\europe.dta", clear;

. *     ****************************************************************  *;
. *       Model 6: Western Europe                                         *;
. *     ****************************************************************  *;
. mixlogit choice largestparty_east party_seatshare_east medianparty1_east presidentparty_east previousPM_east previousPM_conflict_east previousPM_gain1_east previous_cabinet_gain1_east,  
>     rand (largestparty party_seatshare medianparty1 presidentparty previousPM president_investiture president_direct previousPM_conflict previousPM_gain1 previous_cabinet_gain1) 
>     ln(0) nrep(125) group(cabinetcode);

Iteration 0:   log likelihood = -255.29786  (not concave)
Iteration 1:   log likelihood = -245.38797  (not concave)
Iteration 2:   log likelihood =  -228.8695  
Iteration 3:   log likelihood = -221.24204  (not concave)
Iteration 4:   log likelihood = -221.16184  (not concave)
Iteration 5:   log likelihood = -220.39987  
Iteration 6:   log likelihood = -219.61402  
Iteration 7:   log likelihood = -219.46931  
Iteration 8:   log likelihood = -219.42816  (not concave)
Iteration 9:   log likelihood = -219.41127  (not concave)
Iteration 10:  log likelihood = -219.40734  (not concave)
Iteration 11:  log likelihood = -219.38014  
Iteration 12:  log likelihood = -219.35916  
Iteration 13:  log likelihood = -219.35268  
Iteration 14:  log likelihood = -219.35266  

Mixed logit model                                 Number of obs   =       2039
                                                  LR chi2(10)     =      19.54
Log likelihood = -219.35266                       Prob > chi2     =     0.0339

------------------------------------------------------------------------------
      choice |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Mean         |
largestp~ast |  -1.253544   2.017873    -0.62   0.534    -5.208503    2.701414
party_se~ast |   .2877481   .1444587     1.99   0.046     .0046143    .5708819
medianpa~ast |  -3.117227   1.721757    -1.81   0.070    -6.491809    .2573546
presi~y_east |  -.4970681   1.853252    -0.27   0.789    -4.129376     3.13524
previ~M_east |   -2.19965   2.606521    -0.84   0.399    -7.308337    2.909037
previ~t_east |   1.126725   3.208478     0.35   0.725    -5.161776    7.415226
previousPM.. |  -.0930831   .4810077    -0.19   0.847    -1.035841    .8496747
previous_c.. |   .0517841   .1988117     0.26   0.795    -.3378797    .4414479
largestparty |   2.109019   1.104417     1.91   0.056    -.0555996    4.273637
party_seat~e |   .1351541   .0258657     5.23   0.000     .0844583    .1858498
medianparty1 |   1.392319   .3828235     3.64   0.000     .6419985    2.142639
presidentp~y |   5.250695   2.428888     2.16   0.031      .490162    10.01123
  previousPM |   2.841572   1.038968     2.73   0.006     .8052325    4.877912
president_~e |  -3.060496   2.130412    -1.44   0.151    -7.236027    1.115035
president~ct |  -3.915977     2.1442    -1.83   0.068    -8.118531    .2865775
previousP~ct |  -2.618633   1.261868    -2.08   0.038    -5.091848   -.1454174
previousPM~1 |   .4958572   .2007184     2.47   0.013     .1024564     .889258
previous_c~1 |   .0367127   .0403208     0.91   0.363    -.0423147    .1157401
-------------+----------------------------------------------------------------
SD           |
largestparty |   -4.72622   1.779758    -2.66   0.008    -8.214482   -1.237958
party_seat~e |  -.0074871   .0352742    -0.21   0.832    -.0766233    .0616491
medianparty1 |    .137813   .9798871     0.14   0.888     -1.78273    2.058356
presidentp~y |   -.266903   1.275177    -0.21   0.834    -2.766204    2.232398
  previousPM |   -1.90488   1.048407    -1.82   0.069     -3.95972    .1499603
president_~e |  -.4246113   1.592647    -0.27   0.790    -3.546143     2.69692
president~ct |   .5917079    1.45034     0.41   0.683    -2.250906    3.434321
previousP~ct |   -.133958   2.773063    -0.05   0.961    -5.569061    5.301145
previousPM~1 |     .11201   .2052589     0.55   0.585      -.29029    .5143099
previous_c~1 |   .1484155   .0862285     1.72   0.085    -.0205892    .3174201
------------------------------------------------------------------------------
The sign of the estimated standard deviations is irrelevant: interpret them as
being positive

.     *     ****************************************************************  *;
. *       Now produce Figure 1                                            *;
. *     ****************************************************************  *;
. matrix coeffs = e(b);

. matrix covmat = e(V);

. matrix bdraw = coeffs;

. matrix bdraw[1,19] = 0;

. keep if cabinetcode==1222;
(2400 observations deleted)

. set obs 10000;
obs was 12, now 10000

. generate pvda = 0;

. replace pvda = 1 if partyID==7;
(1 real change made)

. generate cda = 0;

. replace cda = 1 if partyID==13;
(1 real change made)

. generate vvd = 0;

. replace vvd = 1 if partyID==22;
(1 real change made)

. generate d66 = 0;

. replace d66 = 1 if partyID==10;
(1 real change made)

. generate ppvda = .;
(10000 missing values generated)

. generate pcda = .;
(10000 missing values generated)

. generate pvvd = .;
(10000 missing values generated)

. generate pd66 = .;
(10000 missing values generated)

. local a=1;

. while `a'<=1853 {;
  2.   matrix bdraw[1,9] = ((`a'-716)/100);
  3.   mixlpred2 pprobs;
  4.    qui generate pvdat = pprobs * pvda;
  5.   qui generate cdat = pprobs * cda;
  6.    qui generate vvdt = pprobs * vvd;
  7.   qui generate d66t = pprobs * d66;
  8.   egen pvdat2 = sum(pvdat);
  9.   egen cdat2 = sum(cdat);
 10.   egen vvdt2 = sum(vvdt);
 11.   egen d66t2 = sum(d66t);
 12.   qui replace ppvda = pvdat2 if _n==`a';
 13.   qui replace pcda = cdat2 if _n==`a';
 14.   qui replace pvvd = vvdt2 if _n==`a';
 15.   qui replace pd66 = d66t2 if _n==`a';
 16.   drop pvdat cdat vvdt d66t
>        pvdat2 cdat2 vvdt2 d66t2 
>        pprobs;
 17.       local a = `a' + 1;
 18.   display "." _c;
 19.     };
.........................................................................................................................................................................................................
> .......................................................................................................................................................................................................
> .......................................................................................................................................................................................................
> .......................................................................................................................................................................................................
> .......................................................................................................................................................................................................
> .......................................................................................................................................................................................................
> .......................................................................................................................................................................................................
> .......................................................................................................................................................................................................
> .......................................................................................................................................................................................................
> ............................................................
. drop if _n>1853;
(8147 observations deleted)

. gen MV= ((_n-716)/100);

.      graph twoway line ppvda MV, clpattern(solid) clwidth(medium) clcolor(black) 
>     || line pcda MV, clpattern(longdash_dot) clwidth(medium) clcolor(black) 
>     || line pvvd MV, clpattern(longdash) clwidth(medium) clcolor(black) 
>     || line pd66 MV, clpattern(shortdash) clwidth(medium) clcolor(black) 
>     ||, 
>     xlabel(-8 -6  -4  -2  0 2  4 6  8  10 12, nogrid) 
>     ylabel (0 0.2 0.4 0.6 0.8 1)  
>     legend(off)  
>     yline(0 0.2 0.4 0.6 0.8 1, lcolor(white)) 
>     xtitle("" , size(2.5))  scheme(s2mono) graphregion(fcolor(white));

.      log close;
      name:  <unnamed>
       log:  C:\fsu2010\formateur\replication\stata_mxl_predictprob.log
  log type:  text
 closed on:  11 Nov 2010, 14:45:58
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
